package com.insta.formation.calendar.dao;

import java.io.Serializable;
import java.util.List;

/**
 * Interface du DAO générique, les méthodes disponibles sont celles d’un CRUD,
 * les interfaces des autres DAO devront étendre celle-ci.
 * 
 * @author julien
 * 
 * @param <T>
 * @param <PK>
 */
public interface IGenericDao<T, PK extends Serializable>
{
	/**
	 * 	Insert a new object in the database
	 * 
	 * @param newInstance - new object
	 * @return - identifier of the object
	 */
	PK create(T newInstance);

	/**
	 * 	Read a object of the database
	 * 
	 * @param id - identifier of the object
	 * @return object of the database, null if not exists
	 */
	T read(PK id);

	/**
	 * 	Read all object of the database
	 * 
	 * @return -  all object of the database
	 */
	List<T> readAll();

	/**
	 * 	Update a object in the database
	 * 
	 * @param transientObject
	 */
	void update(T transientObject);

	/**
	 * 	Delete a object of the database
	 * 
	 * @param persistentObject
	 */
	void delete(T persistentObject);
}